package com.captain.special.二叉树.简单;

import com.captain.leetcode.TreeNode;

import java.util.ArrayList;
import java.util.List;

/**
 * Des:
 *
 * @author XL
 * @Date 2022/5/6 15:36
 */
public class 二叉树的中序遍历94 {
    public List<Integer> inorderTraversal(TreeNode root) {
        List<Integer> res = new ArrayList<>();
        recur(res, root);
        return res;
    }

    public void recur(List<Integer> res, TreeNode node) {
        if (node == null) {
            return;
        }
        recur(res, node.left);
        res.add(node.val);
        recur(res, node.right);
    }
}
